package com.project.common.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.common.entity.PageVo;
import com.project.common.entity.SysMenus;
import com.project.common.entity.SysRoles;
import com.project.common.mapper.SysRolesMapper;
import com.project.common.service.SysRolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Transactional
@Service
public class SysRolesImpl implements SysRolesService {
    @Autowired
    private SysRolesMapper sysRolesMapper;

    @Override
    public PageVo<SysRoles> queryAllRoles(Map<String, String> map) {
        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));
//        System.out.println(map);
        PageHelper.startPage(pageNum,pageSize);
        List<SysRoles> sysRoles = sysRolesMapper.queryAllRoles();

        PageInfo<SysRoles> pageInfo = new PageInfo<SysRoles>(sysRoles);

        PageVo<SysRoles> pageVo = new PageVo<SysRoles>();
        pageVo.setRows(pageInfo.getList());
        pageVo.setTotal(pageInfo.getTotal());

        return pageVo;
    }

    @Override
    public List<SysRoles> queryAllRoles() {
        return sysRolesMapper.queryAllRoles();
    }

    @Override
    public SysRoles selectByPrimaryKey(Integer id) {
        return sysRolesMapper.selectByPrimaryKey(id);
    }
}
